package com.kingsoft.dc.khaos.extender.meta.impl;

import com.alibaba.fastjson.JSON;
import com.kingsoft.dc.khaos.extender.meta.api.DmApiUtils;
import com.kingsoft.dc.khaos.extender.meta.api.DmDatasourceResult;
import com.kingsoft.dc.khaos.extender.meta.api.DmRequest;
import com.kingsoft.dc.khaos.extender.meta.model.ds.Connect;
import com.kingsoft.dc.khaos.extender.meta.model.ds.Datasource;
import com.kingsoft.dc.khaos.extender.meta.model.ds.DmDatasource;
import com.kingsoft.dc.khaos.extender.meta.model.ds.ESConnect;
import com.kingsoft.dc.khaos.extender.meta.utils.RSAEncrypt;

/**
 * create by yansu on 2019/07/10 16:00
 */
public class EsDmMetaImpl extends DmMetaImpl {
    @Override
    public Connect decryptDatasourceConnectSecret(String config) {
        ESConnect esConnect = JSON.parseObject(config, ESConnect.class);

        try {
            esConnect.setPassword(RSAEncrypt.decryptByRSAPassWord(esConnect.getPassword()));
//            esConnect.setKeyStorePass(RSAEncrypt.decryptByRSAPassWord(esConnect.getKeyStorePass()));
//            esConnect.setTrustStorePass(RSAEncrypt.decryptByRSAPassWord(esConnect.getTrustStorePass()));
        } catch (Exception e) {
            e.printStackTrace();
        }

        return esConnect;
    }
}
